Skip to content

refactor: extract self-contained colormaps module#98

Open
patrickoleary wants to merge 1 commit into
masterfrom
refactor/color-module
Open

refactor: extract self-contained colormaps module#98
patrickoleary wants to merge 1 commit into
masterfrom
refactor/color-module

Conversation

@patrickoleary
Copy link
Copy Markdown
Member

@patrickoleary patrickoleary commented May 12, 2026

refactor: use external trame-colormaps package for all colormap functionality

QuickView previously embedded ~1,400 lines of colormap state management,
color transfer function algorithms, log/symlog/discrete transforms, tick
computation, and colorbar/control-panel UI across view_manager.py,
components/view.py, app.py, utils/color.py, and utils/math.py.

All of that is now provided by the trame-colormaps package (>=1.0.0).
Each view creates a ColormapConfig instance that owns the VTK color
transfer function, mapper wiring, preset management, range computation,
and tick generation. The UI is a single HorizontalScalarBar widget call
per view, which renders the colorbar with an integrated popup control
panel for preset selection, scale modes, discrete banding, and manual
range override.

ViewConfiguration retains only layout fields (order, size, offset,
break_row, swap_group). State export/import separates layout config
from colormap config, with backward compatibility for older state files
that stored both in a single "config" key.

@patrickoleary patrickoleary requested a review from jourdain May 12, 2026 15:19
@patrickoleary patrickoleary self-assigned this May 12, 2026
@patrickoleary patrickoleary force-pushed the refactor/color-module branch from cc66b4c to bdc32ec Compare May 13, 2026 21:54
…ionality

QuickView previously embedded ~1,400 lines of colormap state management,
color transfer function algorithms, log/symlog/discrete transforms, tick
computation, and colorbar/control-panel UI across view_manager.py,
components/view.py, app.py, utils/color.py, and utils/math.py.

All of that is now provided by the trame-colormaps package (>=1.0.0).
Each view creates a ColormapConfig instance that owns the VTK color
transfer function, mapper wiring, preset management, range computation,
and tick generation. The UI is a single HorizontalScalarBar widget call
per view, which renders the colorbar with an integrated popup control
panel for preset selection, scale modes, discrete banding, and manual
range override.

ViewConfiguration retains only layout fields (order, size, offset,
break_row, swap_group). State export/import separates layout config
from colormap config, with backward compatibility for older state files
that stored both in a single "config" key.
@patrickoleary patrickoleary force-pushed the refactor/color-module branch from bdc32ec to 19125cf Compare May 17, 2026 12:03
@@ -1176,9 +404,9 @@ def render(self):
self.pending_render = False

def update_color_range(self):
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure you still need that method? What is calling it?

@jourdain
Copy link
Copy Markdown
Collaborator

Code looks good. I'm just not sure about that update_color_range method.

@patrickoleary
Copy link
Copy Markdown
Member Author

It is necessary. update_color_range is in view_manager.py and in trame-colormaps.py. The ViewManager method just loops over all views and calls view.colormap.update_color_range() on each ColormapConfig when quickview changes the data (_on_slicing_change and _on_downstream_change). The ColormapConfig.update_color_range() in trame-colormaps knows how to recompute (re-read the data array, rescale the CTF, reapply the preset). This split is correct. trame-colormaps doesn't know about QuickView's pipeline lifecycle, so QuickView triggers the recompute at the right moments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants